{extends 'admin/layout/table-main.tpl'}

{block title}菜单管理{/block}
{block smallTitle}系统内的菜单管理。{/block}

{block main}
<div class="ibox float-e-margins">
	<div class="ibox-content">
		<div class="row row-lg">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-content">
						<h4 class="example-title">{block title}{/block}</h4>
						<div class="btn-group hidden-xs" id="exampleTableEventsToolbar" role="group">
							<a type="button" href="{route('AdminMenuLoadList')}" class="btn btn-outline btn-default">
								<i class="icon-download-alt" aria-hidden="true"></i>导入菜单</a>
							<a type="button" class="btn btn-outline btn-default" href="{route('AdminMenuEdit')}">
								<i class="glyphicon glyphicon-plus" aria-hidden="true">添加菜单</i>
							</a>
						</div>
						<table class="table table-striped">
							<thead>
							<tr>
								<th>菜单名称</th>
								<th>路由别名</th>
								<th>是否有效</th>
								<th>排序</th>
								<th>操作</th>
							</tr>
							</thead>
							<tbody>
							{foreach $data as $item}
								<tr data-id="{$item.id}" data-name="{$item.name|escape}" data-type="menu">
									<td>{$item.option}{$item.deep}</td>
									<td>{$item.route}</td>
									<td>{if $item.status=='Yes'}有效{else}无效{/if}</th>
									<td>{$item.sort}</td>
									<td class="text-navy">
										<a class="btn btn-xs btn-info" href="{route('AdminMenuEdit', ['id'=>$item.id])}"><i class="fa fa-edit"></i> 编辑</a>
										<button class="btn btn-xs btn-danger" type="button" data-role="delete"><i class="fa fa-trash-o"></i> 删除</button>
									</td>
								</tr>
							{/foreach}
							</tbody>
						</table>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
{/block}

{block script}
	<script>
		$(document).ready(function(){
			$('[data-role="delete"]').on('click', function(){
				var data = $(this).parents('tr').data();
				iconfirm({
					action	: '{route('AdminMenuDelete')}',
					body		: '确定要删除菜单 ' + data.name + ' 吗？',
					data		: data
				});
				return false;
			});
		})
	</script>
{/block}
